<?php
namespace Apps\BoxSns\Model;

use Think\Model;

class SnsMessageModel extends \BaseModel
{

    /***********消息入库****/
    public function send($from_id, $to_id, $content)
    {
        $_message = BoxModel("SnsMessage");
        $box_id = $from_id > $to_id ? $to_id . "_" . $from_id : $from_id . "_" . $to_id;
        $row = array(
            'box_id' => $box_id,
            'content' => $content,
            'user_id' => $from_id,
            'add_time' => time(),
        );
        $id = $_message->add($row);
        if ($id) {
            $r = BoxModel("sns_message_record")->record($from_id, $to_id, $box_id);
        }
        if ($id && $r) {
            return $id;
        } else {
            return false;
        }
    }


}
 